<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #box img {
        width: 200px;
        height: 200px;
      }
    </style>
  </head>
  <body>
    <div id="box">
      <img src="./img/longmao.webp" alt="" id="img" />
    </div>
    <button id="btn">龙猫</button>
    <button id="del">删除</button>

    <script>
      // document.getElementById('btn').onclick = function () {
      //   var imgEle = document.createElement('img');
      //   imgEle.src = './img/mini2.jpg';
      //   document.getElementById('box').appendChild(imgEle);
      // };

      //   document.getElementById('del').onclick = function () {
      //     var imgEle = document.getElementById('img');
      //     var boxEle = document.getElementById('box');
      //     boxEle.removeChild(imgEle);
      //   };

      var del = document.getElementById('del');
      del.onclick = function () {
        var imgEle = document.getElementById('img');
        var newImg = imgEle.cloneNode(true);
        var boxEle = document.getElementById('box');
        boxEle.appendChild(newImg);
      };
    </script>
  </body>
</html>
